
// select
	$('.fq_select').click(function(event) {
		$('.fq_default').attr('data-fqdefault',1) 
		$('.fq_select').css({
			"opacity":"1"
		})
		$('.fq_default').empty()
	});

// textarea
	$('.textarea').on('input propertychange', function() {
	// $('.textarea').keydown(function(event) {
		var textareaval = $(this).val().length
		$('#textarea_num').html(textareaval)
		if (textareaval>0 && textareaval<11) {
			$('#textarea_num ').addClass('red')
		}else{
			$('#textarea_num ').removeClass('red')
		}
	});

// picture

	$('.fq_picture_list li').height($('.fq_picture_list li').width())
	var picturelength =  $('.fq_picture_list li').length
	$('.fq_picture_list li:last-child').addClass('add')



	$(document).on('click', '.delete', function(event) {
		$(this).parent().remove()
		if (picturelength<4) {
			$('#add').show()
			$('#fq_picture_num').text($('.fq_picture_list li').length-1)
		}else{
			$('#fq_picture_num').text($('.fq_picture_list li').length)
		}

	});

// 自定义弹窗
	function mask_ts(data){
			var mask_ts = $('<div class="mask_ts"></div>')
			$('body').append(mask_ts.text(data))
			setTimeout(function(){
				mask_ts.animate({opacity:0});
			},2000)
			setTimeout(function(){
				mask_ts.remove()
			},2500)
	}


	var information = decodeURIComponent((new RegExp('[?|&]information=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
	
// 提交事件处理
	$('.submit_btn').click(function(event) {
		if (lan == 'cn') {
			if ($('.fq_default').attr('data-fqdefault')== 0) {
				mask_ts('请选择问题类型')
			}else if ($('.textarea').val().length==0) {
				mask_ts('请输入问题描述')
			}else if ($('.textarea').val().length <=10) {
				mask_ts('至少10字问题描述')
			}
		}else if (lan == 'en') {
			if ($('.fq_default').attr('data-fqdefault')== 0) {
				mask_ts('Please select the problem type.')
			}else if ($('.textarea').val().length==0) {
				mask_ts('Please enter a problem description.')
			}else if ($('.textarea').val().length <=10) {
				mask_ts('Please enter a problem description not less than 10 words.')
			}

		}else if (lan == 'ko') {
			if ($('.fq_default').attr('data-fqdefault')== 0) {
				mask_ts('문제점타입을 선택하세요')
			}else if ($('.textarea').val().length==0) {
				mask_ts('문제점를 입력하여 제출하세요')
			}else if ($('.textarea').val().length <=10) {
				mask_ts('10자리이상을 입력하여 문제점를 제출하세요')
			}

		}
		

		if ($('.fq_default').attr('data-fqdefault')==1 && $('.textarea').val().length >10) {
			// var AppVersion = decodeURIComponent((new RegExp('[?|&]AppVersion=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
			// var MobileModel = decodeURIComponent((new RegExp('[?|&]MobileModel=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
			// var MobileSystem = decodeURIComponent((new RegExp('[?|&]MobileSystem=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
			// var uid = decodeURIComponent((new RegExp('[?|&]uid=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;

		
			
			var type = $('.fq_select').find("option:selected").val()
			var content =$('.textarea').val()
			var contact =$('.fq_tel_input').val()
			var imgArr = []
			// console.log(information)
			$('.fq_picture_list img').each(function(index, el) {
				imgArr.push($(this).attr('data-img'))
			});
			// console.log(imgArr)
			$.ajax({
				url: '/h5/feedback/feedbacksub',
				type: 'POST',
				dataType: 'json',
				data: {
					type: type,
					content:content,
					img: imgArr,
					contact:contact,
					information:information
				}
			})
			.done(function(data) {
 
				if (data.code==1) {
					// $('.sub_ok ,.sub_okmask').show()
		
					if (lan == 'cn') {
						alert('感谢您的支持，我们会尽快处理。')
						// var msg = "感谢您的支持，我们会尽快处理。"; 
						// if (confirm(msg) == true) {
						// 	//alert(0)
						// 	return true;
						// } else {
						// 	return false;
						// }

					}else if (lan == 'en') {
						alert('Thank you for your support, we will handle it as soon as possible.')

					}else if (lan == 'ko') {
						alert('지원해주셔서 감사합니다.빠른 시간내에 처리하겠습니다')
					}



					



					


				}
				// console.log(data)
			})
			.fail(function(data) {

				console.log(data);
			})
			

			
			
		

		}
	});

